// pages/meirituijian/meirituijian.js
Page({

  /**
   * 页面的初始数据
   */
  /*
  位置代码:东2 中3 西5 该代码采用质数编码，若某点同时位于多地则将其乘积作为位置代码
  */
  data: {
    naicha:[
      {shop:"私品茶道",name:"金萱乌龙柠檬茶",location:5},
      {shop:"私品茶道",name:"小玉园奶茶",location:5},
      {shop:"私品茶道",name:"奥利奥脏脏可可",location:5},
      {shop:"私品茶道",name:"兰香乌龙拿铁",location:5},
      {shop:"私品茶道",name:"小芋圆烧仙草",location:5},
      {shop:"私品茶道",name:"月桂乌龙奶茶",location:5},
      {shop:"私品茶道",name:"四季奶昔",location:5},
      {shop:"私品茶道",name:"火龙果酸奶",location:5},
      {shop:"私品茶道",name:"月桂乌龙奶茶",location:5},
      {shop:"蜜雪冰城",name:"现熬烧仙草",location:5},
      {shop:"蜜雪冰城",name:"三拼霸霸奶茶",location:5},
      {shop:"蜜雪冰城",name:"珍珠奶茶",location:5},
      {shop:"蜜雪冰城",name:"满杯百香果",location:5},
      {shop:"蜜雪冰城",name:"蜜桃四季春",location:5},
      {shop:"蜜雪冰城",name:"雪王大圣代",location:5},
      {shop:"蜜雪冰城",name:"芝士奶盖红茶",location:5},
      {shop:"研茶",name:"黑糖珍珠奶茶",location:3},
      {shop:"研茶",name:"大红袍珍珠奶茶",location:3},
      {shop:"研茶",name:"红豆可可",location:3},
      {shop:"研茶",name:"金牌杨枝甘露",location:3},
      {shop:"研茶",name:"芋泥麦麦奶茶",location:3},
      {shop:"研茶",name:"芋泥牛乳小丸子",location:3},
      {shop:"研茶",name:"黑糖珍珠圣代",location:3},
      {shop:"港饮之港",name:"三兄弟奶茶",location:6},
      {shop:"港饮之港",name:"皇家珍珠奶茶",location:6},
      {shop:"港饮之港",name:"蜂蜜柚子",location:6},
      {shop:"港饮之港",name:"草莓酸奶多",location:6},
      {shop:"书亦烧仙草",name:"书亦烧仙草",location:15},
      {shop:"书亦烧仙草",name:"椰椰烧仙草",location:15},
      {shop:"书亦烧仙草",name:"黑糖小芋圆奶茶",location:15},
      {shop:"书亦烧仙草",name:"牛魔王黑砖奶茶",location:15},
      {shop:"益禾堂",name:"云海大红袍",location:6},
      {shop:"益禾堂",name:"益禾烤奶",location:6},
      {shop:"益禾堂",name:"翠峰茉莉",location:6},
      {shop:"益禾堂",name:"冻柠蜜",location:6},
      {shop:"茶玛",name:"芒芒波奶椰",location:5},
      {shop:"茶玛",name:"芋泥波奶椰",location:5},
      {shop:"茶玛",name:"莓莓波奶椰",location:5},
      {shop:"茶玛",name:"杨枝甘露吸吸冻",location:5},
      {shop:"茶玛",name:"枝枝豆乳奶茶",location:5},
      {shop:"一点点",name:"茉莉绿茶",location:2},
      {shop:"一点点",name:"奶茶",location:2},
      {shop:"一点点",name:"柠檬汁",location:2},
      {shop:"一点点",name:"波霸奶茶",location:2},
      {shop:"一点点",name:"茉莉绿茶",location:2},
      {shop:"茶百道",name:"奥利奥芝士",location:2},
      {shop:"茶百道",name:"招牌芋圆",location:2},
      {shop:"茶百道",name:"芋圆拿铁",location:2},
      {shop:"茶百道",name:"芒果绿茶",location:2},
      {shop:"茶百道",name:"杨枝甘露",location:2},
      
    ],
    tabs:[
      {id:2,name:"东边",active:true},
      {id:3,name:"中间",active:false},
      {id:5,name:"西边",active:false}
    ],
    active_id:2,
    trans:[2,3,5],
    good:{},
    showing_content:{},
    random_num:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({active_id:2})
  },
  hindleTabTaps:function(e){
    const {index} = e.currentTarget.dataset;
    if(this.data.trans[index] === this.data.tabs[0].id){
      this.setData({tabs:[
        {id:2,name:"东边",active:true},
        {id:3,name:"中间",active:false},
        {id:5,name:"西边",active:false}
      ],
      active_id:this.data.trans[index]
    });
    }
    else if(this.data.trans[index] === this.data.tabs[1].id){
      this.setData({tabs:[
        {id:2,name:"东边",active:false},
        {id:3,name:"中间",active:true},
        {id:5,name:"西边",active:false}
      ],
      active_id:this.data.trans[index]
    })
    }
    else if(this.data.trans[index] === this.data.tabs[2].id){
      this.setData({tabs:[
        {id:2,name:"东边",active:false},
        {id:3,name:"中间",active:false},
        {id:5,name:"西边",active:true}
      ],
      active_id:this.data.trans[index]
    })
    }
  },
  random_choose:function(){
    while(1){
      this.data.random_num = Math.ceil(Math.random()*this.data.naicha.length) - 1;
      if(this.data.random_num<0) this.data.random_num+=1;
      if(((this.data.naicha)[this.data.random_num]).location % this.data.active_id === 0){
        this.setData(
          {
            showing_content:this.data.naicha[this.data.random_num]
          }
        )
        break;
      }
    }
      
  }
})
